package cpa.prowon.gui;

import cpa.prowon.image.ImageContainer;

/**
 * The single image information window is used to edit the IPTC infomration
 * of a single image
 * @author Chris
 */
public class SingleImageInformationWindow extends ImageInformationWindow {

	// Properties
	protected ImageContainer _image;
	
	/**
	 * Get the number of columns for the group widget
	 * @return The number of columns
	 * @author Chris
	 */
	protected int getGroupColumnsNumber() {
		return 2;
	}
	
	/**
	 * Get the title of the image
	 * @return The actual value
	 * @author Chris
	 */
	public SingleImageInformationWindow(MainWindow w, ImageContainer image) {
		
		// Create the object
		super();
		
		// Set the initial values
		mainWindow = w;
		_image = image;
		
	}

	/**
	 * Get the title of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getTitle() {
		return _image.getTitle();
	}

	/**
	 * Get the gallery of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getGallery() {
		return _image.getGallery();
	}

	/**
	 * Get the description of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getDescription() {
		return _image.getDescription();
	}

	/**
	 * Get the keywords of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getKeywords() {
		String[] keywordList = _image.getKeywords();
		String tempKeywords = "";
		boolean isFirst = true;
		for (int i=1; i<=keywordList.length; i++) {
			if (isFirst == true) {
				isFirst = false;
			} else {
				tempKeywords += "\r\n";
			}
			tempKeywords += keywordList[i-1];
		}
		return tempKeywords;
	}

	/**
	 * Get the supplemental categories of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getSupplementalCategories() {
		String[] catList = _image.getSupplementalCategories();
		String tempCats = "";
		boolean isFirst = true;
		for (int i=1; i<=catList.length; i++) {
			if (isFirst == true) {
				isFirst = false;
			} else {
				tempCats += "\r\n";
			}
			tempCats += catList[i-1];
		}
		return tempCats;
	}

	/**
	 * Get the city of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getCity() {
		return _image.getCity();
	}

	/**
	 * Get the state of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getProvinceState() {
		return _image.getProvinceState();
	}

	/**
	 * Get the country of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getCountry() {
		return _image.getCountry();
	}

	/**
	 * Get the category of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getCategory() {
		return _image.getCategory();
	}

	/**
	 * Get the copyright of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getCopyright() {
		return _image.getCopyright();
	}

	/**
	 * Get the date of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getDate() {
		return _image.getDate();
	}

	/**
	 * Get the originating program of the image
	 * @return The actual value
	 * @author Chris
	 */
	protected String getOriginatingProgram() {
		return _image.getOriginatingProgram();
	}

	/**
	 * Set the title of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setTitle(String value) {
		_image.setTitle(value);
	}

	/**
	 * Set the gallery of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setGallery(String value) {
		_image.setGallery(value);
	}

	/**
	 * Set the description of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setDescription(String value) {
		_image.setDescription(value);
	}

	/**
	 * Set the keywords of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setKeywords(String value) {
		_image.setKeywords(value.split("\r\n"));
	}

	/**
	 * Set the supplemental categories of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setSupplementalCategories(String value) {
		_image.setSupplementalCategories(value.split("\r\n"));
	}

	/**
	 * Set the city of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setCity(String value) {
		_image.setCity(value);
	}

	/**
	 * Set the state of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setProvinceState(String value) {
		_image.setProvinceState(value);
	}

	/**
	 * Set the country of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setCountry(String value) {
		_image.setCountry(value);
	}

	/**
	 * Set the category of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setCategory(String value) {
		_image.setCategory(value);
	}

	/**
	 * Set the copyright of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setCopyright(String value) {
		_image.setCopyright(value);
	}

	/**
	 * Set the date of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setDate(String value) {
		_image.setDate(value);
	}

	/**
	 * Set the originating program of the image
	 * @param String The actual value
	 * @author Chris
	 */
	protected void setOriginatingProgram(String value) {
		_image.setOriginatingProgram(value);
	}

	/**
	 * Save the changes
	 * @author Chris
	 */
	protected void save() {
		if (_image.hasChanged()) {
			_image.save();
		}
	}

}
